package com.cskaoyan.wordmemorize.controller.app;

import com.cskaoyan.wordmemorize.auth.StpKit;
import com.cskaoyan.wordmemorize.common.result.Result;
import com.cskaoyan.wordmemorize.dto.admin.PageDTO;
import com.cskaoyan.wordmemorize.dto.admin.VocDTO;
import com.cskaoyan.wordmemorize.dto.app.DisplayBookVocDTO;
import com.cskaoyan.wordmemorize.dto.app.DisplayChapterDTO;
import com.cskaoyan.wordmemorize.request.AppVocPageRequest;
import com.cskaoyan.wordmemorize.service.VocService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
@Tag(name = "移动端-单词模块相关接口")
@RestController
public class AppVocServiceController {
    @Autowired
    VocService vocService;
    //APP端获取无章节的书籍单词列表
    //PageDTO<DisplayBookVocDTO> getDisplayBookVocsInfo(AppVocPageRequest pageRequest);
    @GetMapping("/user/voc/book/display")
    public Result<PageDTO<DisplayBookVocDTO>> getDisplayBookVocsInfo(AppVocPageRequest pageRequest) {
        PageDTO<DisplayBookVocDTO> pageDTO=vocService.getDisplayBookVocsInfo(pageRequest);
        return Result.ok(pageDTO);
    }
    //PageDTO<DisplayChapterDTO> getDisplayBookChapterVocsInfo(AppVocPageRequest pageRequest);
    @GetMapping("/user/voc/book/chapter/display")
    public Result<PageDTO<DisplayChapterDTO>> getDisplayBookChapterVocsInfo(AppVocPageRequest pageRequest) {
        PageDTO<DisplayChapterDTO> pageDTO=vocService.getDisplayBookChapterVocsInfo(pageRequest);
        return Result.ok(pageDTO);
    }
    ///user/voc/detail/{vocId}
    @GetMapping("user/voc/detail/{vocId}")
    public Result<VocDTO> getVocDetail(@PathVariable("vocId") Long vocId) {
        Long userId=StpKit.USER.getLoginIdAsLong();
        VocDTO vocDetail=vocService.getVocDetail(vocId,userId);
        return Result.ok(vocDetail);
    }
}
